package com.nowcoder.community.dao;

import com.nowcoder.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

@Mapper
@Deprecated     // 不推荐使用
public interface LoginTicketMapper {

    // sql
    @Insert({
            "insert into `community`.`login_ticket`(user_id,ticket,status,expired) ",
            "value (#{userId},#{ticket},#{status},#{expired});"
    })
    // 自动生成主键,指定主键
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertLoginTicket(LoginTicket loginTicket);

    @Select({
            "select id,user_id,ticket,status,expired ",
            "from `community`.`login_ticket` ",
            "where ticket = #{ticket};"
    })
    LoginTicket selectLoginTicket(String ticket);

    @Update({
            "update `community`.`login_ticket` ",
            "set status = #{status} ",
            "where ticket = #{ticket}; ",
    })
    int upadateStatus(String ticket, int status);
}
